<style>
  .red {
    color: red;
  }
</style>

<div id="app"></div>

<script>
  function h(tag, props, children) {
    return {
      tag,
      props,
      children
    }
  }

  function mount(vnode, container) {
    const el = document.createElement(vnode.tag);
    // props
    if (vnode.props) {
      for (const key in vnode.props) {
        const value = vnode.props[key]
        el.setAttribute(key, value)
      }
    }
    // children
    if (vnode.children) {
      if (typeof vnode.children === 'string') {
        el.textContent = vnode.children
      } else {
        vnode.children.forEach(child => {
          mount(child, el)
        })
      }
    }
    container.appendChild(el);
  }

  const vdom = h('div', { class: 'red' }, [
    h('span', null, 'hello')
  ])

  // 虚拟dom => 真实dom
  mount(vdom, document.getElementById('app'))


  // old 快照 new 
  function patch(n1, n2) {

  }
</script>